package com.ydkj.a37e_mall.Resource.Utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * SharedPreferences工具�?
 *
 * @author Administrator
 */
public class SharedPreferencesUtil {

    public static final String FILENAME = "SharedPreferences";

    public static final String FIRSTRUN = "firstrun";

    public static final String SID = "sid";

    public static final String ID = "id";

    public static final String INTEGRAL = "integral";

    //经纬度
    public static final String JINGDU = "jingdu";

    public static final String WEIDU = "weidu";

    //推送数
    public static final String PUSH = "PUSH";

    //会员消息
    public static final String VIPMESSAGE = "VIPMESSAGE";

    //系统消息
    public static final String SYSTEMMESSAGE = "SYSTEMMESSAGE";

    //字體
    public static final String LANGUAGE = "LANGUAGE";

    /**
     * 用户�?
     */
    public static final String USERNAME = "username";

    /**
     * 用户id
     */
    public static final String USERID = "userid";

    /**
     * 密码
     */
    public static final String PASSWORD = "password";

    /**
     * 是否提示过系统更新信�?
     */
    public static final String VERSION = "version";

    /**
     * 更新信息
     */
    public static final String UPDATEMSG = "updatemsg";

    /**
     * wifi加载图片
     */
    public static final String WIFILOAD = "wifiload";

    /**
     * 系统消息
     */
    public static final String SYSTEMMSG = "systemmsg";

    /**
     * 圈子消息
     */
    public static final String CIRCLEMSG = "circlemsg";

    /**
     * 好友消息
     */
    public static final String FRIENDMSG = "friendmsg";

    /**
     * 声音
     */
    public static final String VOICE = "voice";

    /**
     * 震动
     */
    public static final String VIBRATE = "vibrate";

    /**
     * 密码
     */
    public static final String CITYCODE = "citycode";

    /**
     * access_token
     */
    public static final String ACCESS_TOKEN = "access_token";

    /**
     * 城市编码
     */
    public static final String CITYNAME = "cityname";

    /**
     * 城市编码
     */

    public static final String COOKIE = "cookie";

    /**
     * 第三方登录的 open_id
     */
    public static final String OPEN_ID = "open_id";

    /**
     * 第三方登录的类型
     */
    public static final String TYPE = "type";

    /**
     * 第三方登录的用户name
     */
    public static final String NICKNAME = "nickname";
    /**
     * 第三方登录的用户头像
     */
    public static final String AVATAR = "avatar";


    private static SharedPreferencesUtil instance;
    private SharedPreferences settings;

    private Editor editor;

    private SharedPreferencesUtil(Context context) {
        settings = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
        editor = settings.edit();
    }

    /**
     * 配置�?要区分用户名存储�?
     *
     * @param context
     * @return
     */
    public static SharedPreferencesUtil getInstance(Context context) {
        if (instance == null) {
            instance = new SharedPreferencesUtil(context);
        }
        return instance;
    }

    public SharedPreferences getSharedPreferences() {
        return settings;
    }

    public Editor getEditor() {
        return editor;
    }

    /**
     * 清空�?有数�?
     */
    public void clearAllData() {
        editor.clear();
        editor.commit();
    }

    public String getCitycode() {
        return settings.getString(CITYCODE, "");// 厦门编号16278
    }

    public void setCitycode(String citycode) {
        editor.putString(CITYCODE, citycode);
        editor.commit();
    }

    public String getCityname() {
        return settings.getString(CITYNAME, "");
    }

    public void setCityname(String cityname) {
        editor.putString(CITYNAME, cityname);
        editor.commit();
    }

    public String getAccessToken() {
        return settings.getString(ACCESS_TOKEN, "");
    }

    public void setAccessToken(String accessToken) {
        editor.putString(ACCESS_TOKEN, accessToken);
        editor.commit();
    }


    public String getAvatar() {
        return settings.getString(AVATAR, "");
    }

    public void setAvatar(String accessToken) {
        editor.putString(AVATAR, accessToken);
        editor.commit();
    }
    public String getNickname() {
        return settings.getString(NICKNAME, "");
    }

    public void setNickname(String accessToken) {
        editor.putString(NICKNAME, accessToken);
        editor.commit();
    }

    public String getType() {
        return settings.getString(TYPE, "");
    }

    public void setType(String accessToken) {
        editor.putString(TYPE, accessToken);
        editor.commit();
    }

    public String getOpen_id() {
        return settings.getString(OPEN_ID, "");
    }

    public void setOpen_id(String accessToken) {
        editor.putString(OPEN_ID, accessToken);
        editor.commit();
    }

    public String getIntegral() {
        return settings.getString(INTEGRAL, "");
    }

    public void setIntegral(String ub) {
        editor.putString(INTEGRAL, ub);
        editor.commit();
    }

    public String getSid() {
        return settings.getString(SID, "");
    }

    public void setSid(String sid) {
        editor.putString(SID, sid);
        editor.commit();
    }

    public String getUsername() {
        return settings.getString(USERNAME, "");
    }

    public void setUsername(String username) {
        editor.putString(USERNAME, username);
        editor.commit();
    }

    public void setJingdu(String jingdu) {
        editor.putString(JINGDU, jingdu);
        editor.commit();
    }

    public String getJingdu() {
        return settings.getString(JINGDU, "0");
    }

    public void setWeidu(String weidu) {
        editor.putString(WEIDU, weidu);
        editor.commit();
    }

    public String getWeidu() {
        return settings.getString(WEIDU, "0");
    }

    public String getId() {
        return settings.getString(ID, "");
    }

    public void setId(String id) {
        editor.putString(ID, id);
        editor.commit();
    }

    public int getPush() {
        return settings.getInt(PUSH, 0);
    }

    public void setPush(int num) {
        editor.putInt(PUSH, num);
        editor.commit();
    }

    public int getVipMessage() {
        return settings.getInt(VIPMESSAGE, 0);
    }

    public void setVipMessage(int num) {
        editor.putInt(VIPMESSAGE, num);
        editor.commit();
    }

    public int getSystemMessage() {
        return settings.getInt(SYSTEMMESSAGE, 0);
    }

    public void setSystemMessage(int num) {
        editor.putInt(SYSTEMMESSAGE, num);
        editor.commit();
    }

    public void setLanguage(String language) {
        editor.putString(LANGUAGE, language);
        editor.commit();
    }

    public String getLanguage() {
        return settings.getString(LANGUAGE, "0");
    }

    public int getFirstRun() {
        return settings.getInt(FIRSTRUN, 0);
    }

    public void setFirstRun(int num) {
        editor.putInt(FIRSTRUN, num);
        editor.commit();
    }

    public String getPassword() {
        return settings.getString(PASSWORD, "");
    }

    public void setPassword(String password) {
        editor.putString(PASSWORD, password);
        editor.commit();
    }

    public String getVersion() {
        return settings.getString(VERSION, "1.0");
    }

    public void setVersion(String version) {
        editor.putString(VERSION, version);
        editor.commit();
    }

    public String getUpdateMsg() {
        return settings.getString(UPDATEMSG, "");
    }

    public void setUpdateMsg(String updateMsg) {
        editor.putString(UPDATEMSG, updateMsg);
        editor.commit();
    }

    public Boolean getWifiLoad() {
        return settings.getBoolean(WIFILOAD, true);
    }

    public void setWifiLoad(Boolean updateMsg) {
        editor.putBoolean(WIFILOAD, updateMsg);
        editor.commit();
    }

    public Boolean getSystemMsg() {
        return settings.getBoolean(SYSTEMMSG, true);
    }

    public void setSystemMsg(Boolean systemmsg) {
        editor.putBoolean(SYSTEMMSG, systemmsg);
        editor.commit();
    }

    public Boolean getCircleMsg() {
        return settings.getBoolean(CIRCLEMSG, true);
    }

    public void setCircleMsg(Boolean circlemsg) {
        editor.putBoolean(CIRCLEMSG, circlemsg);
        editor.commit();
    }

    public Boolean getFriendMsg() {
        return settings.getBoolean(FRIENDMSG, true);
    }

    public void setFriendMsg(Boolean friendmsg) {
        editor.putBoolean(FRIENDMSG, friendmsg);
        editor.commit();
    }

    public Boolean getVoice() {
        return settings.getBoolean(VOICE, true);
    }

    public void setVoice(Boolean voice) {
        editor.putBoolean(VOICE, voice);
        editor.commit();
    }

    public Boolean getVibrate() {
        return settings.getBoolean(VIBRATE, true);
    }

    public void setVibrate(Boolean vibrate) {
        editor.putBoolean(VIBRATE, vibrate);
        editor.commit();
    }

    public String getCookie() {
        return settings.getString(COOKIE, "");
    }

    public void setCookie(String cookie) {
        editor.putString(COOKIE, cookie);
        editor.commit();
    }

    public String getUSERID() {
        return settings.getString(USERID, "");
    }

    public void setUSERID(String userid) {
        editor.putString(USERID, userid);
        editor.commit();
    }
}
